import requests
from lxml import etree

url = 'https://www.ahzww.net/7/7298/2889674.html'
headers = {
    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
}
r = requests.get(url=url, headers=headers)
html = etree.HTML(r.content.decode('gbk'))
comment_list = html.xpath('//div[@id="content"]/p/text()')
print(comment_list)
print("提取到的个数：", len(comment_list))

g = open('./斗罗大陆.txt   ', 'w', encoding='utf-8')
for temp in comment_list:
    g.write(temp)

